/**
 * @author 徐楠
 * @date 2022/4/27 22:12
 * @version 1.0
 */

package com.xunan.likou;

public class CanTheRobotReturnToTheOrigin {
    public static void main(String[] args) {
        String moves = "UD";
        boolean b = judgeCircle(moves);
        System.out.println(b);
    }

    public static boolean judgeCircle(String moves) {
        int i = 0;
        int j = 0;
        for (int m = 0; m < moves.length(); m++) {
            if (moves.charAt(m) == 'U') {
                j++;
            } else if (moves.charAt(m) == 'D') {
                j--;
            } else if (moves.charAt(m) == 'L') {
                i--;
            } else if (moves.charAt(m) == 'R') {
                i++;
            }
        }
        if (i != 0 || j != 0) {
            return false;
        }
        return true;
    }
}
